namespace MiniFlower
{
    public class WorldContext
    {
        private IGameWorld m_ThisCurrentWorld;

        private IGameInstance m_OwningGameInstance;

        public IGameInstance OwningGameInstance
        {
            get { return m_OwningGameInstance; }
            set { m_OwningGameInstance = value; }
        }

        public WorldContext()
        {
            m_ThisCurrentWorld = null;
        }

        public void SetCurrentWorld(IGameWorld gameWorld)
        {
            IGameWorld oldWorld = m_ThisCurrentWorld;
            m_ThisCurrentWorld = gameWorld;

            if (m_OwningGameInstance != null)
            {
                m_OwningGameInstance.OnWorldChanged(oldWorld, m_ThisCurrentWorld);
            }
        }

        public IGameWorld GetWorld()
        {
            return m_ThisCurrentWorld;
        }
    }
}
